package com.mergeades.chp08;

import java.util.concurrent.CyclicBarrier;

public class CyclicBarrierTest {

    static CyclicBarrier cb = new CyclicBarrier(3);

    public static void main(String[] args) throws Exception {
        new Thread(()->{
            try {
                cb.await();
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(1);
        }).start();

        new Thread(()->{
            try {
                cb.await();
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(2);
        }).start();

        cb.await();
        System.out.println(3);
    }
}
